package com.moon.common;

import com.moon.common.type.JoinType;

@SuppressWarnings("unchecked")
public class SuperQuery {

	Class fromClazz;
	Class joinClazz;
	String joinField;
	String joinType;
	String fromExpress;
	String whereExpress;
	String alias;
	private int count=0;
	
	public SuperQuery(Class fromClazz, Class joinClazz, String joinField,String joinType) {
		this.fromClazz = fromClazz;
		this.joinClazz = joinClazz;
		this.joinField = joinField;
		this.joinType = joinType;
		this.fromExpress="from "+fromClazz.getSimpleName()+" "+fromClazz.getSimpleName()+"_0 "
						+joinType+" "+joinClazz.getSimpleName()+" "+joinClazz.getSimpleName()+"_1"+" on "+fromClazz.getSimpleName()+"_1"+"."+joinField+"="+joinClazz.getSimpleName()+"_0."+joinField;
		System.out.println(this.fromExpress);
	}

	public SuperQuery(Class fromClazz) {
		this.fromClazz = fromClazz;
		this.fromExpress="from "+fromClazz.getSimpleName();
	}

	public Class getFromClazz() {
		return fromClazz;
	}

	public void setFromClazz(Class fromClazz) {
		this.fromClazz = fromClazz;
	}

	public Class getJoinClazz() {
		return joinClazz;
	}

	public void setJoinClazz(Class joinClazz) {
		this.joinClazz = joinClazz;
	}

	public String getJoinField() {
		return joinField;
	}

	public void setJoinField(String joinField) {
		this.joinField = joinField;
	}
	public static void main(String[] args) {
		new SuperQuery(Object.class,String.class,"id",JoinType.INNER);
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public String getAlias() {
		return +count+++" ";
	}
}
